<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>沙漏加载动画</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        body {
            width: 100vw;
            height: 100vh;
            background: linear-gradient(200deg,#b5aee4,#505285);
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .loading {
            width:86px ;
            height: 196px;
            /* background: plum; */
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-direction: column;
            position: relative;
            animation: rotate 2s linear infinite;
        }
        .top,.bottom {
            width: 70px;
            height: 70px;
            /* background-color: coral; */
            border-style: solid;
            border-color: #dcdcdc;
            border-width: 4px 4px 12px 12px;
            border-radius: 50% 100% 50% 30%;
            position: relative;
            overflow: hidden;
        }
        .top {
            transform: rotate(-45deg);
        }
        .bottom {
            transform: rotate(135deg);
        }
        /* 容器里的沙 */
        .top::before,
        .bottom::before {
            content: "";
            position: absolute;
            width: inherit;
            height: inherit;
            background:#cabbe9 ;
        }
        .top::before {
             /* 通过设置圆角来改变沙的形状 */
            border-radius: 0 100% 0 0 ;
            animation: drop 2s linear infinite;
        }
        .bottom::before {
            border-radius: 0 0 0 25%;
            transform: translate(50px,-50px);
            animation: fill 2s linear infinite;
        }
        @keyframes drop {
            100% {
                transform: translate(-50px,50px);
            }
        }
        @keyframes fill {
            100% {
                transform: translate(0,0);
            }
        }
        .loading::after {
            content: "";
            position: absolute;
            width: 5px;
            height: 96px;
            background-color: #cabbe9;
            top: 20px;
            animation: flow 2s linear infinite;
        }
        @keyframes flow {
            10%,100% {
                transform: translateY(64px);
            }
        }
        @keyframes rotate {
            0%,90% {
                transform: rotate(0deg);
            }
            100% {
                transform: rotate(180deg);
            }
        }


    </style>
</head>
<body>
    <div class="loading">
        <span class="top"></span>
        <span class="bottom"></span>
    </div>
    
</body>
</html>